<template>
	<view class="global">
		<view class="ddzx" style="margin-bottom: 10px;">
			<view class="">
				订单信息
			</view>
			<view class="">
				课程名称:{{obk.courseTitle}}
			</view>
			<view class="">
				授课老师:{{obk.teacherName}}
			</view>
			<view class="">
				订单编号:{{obk.orderNo}}
			</view>
		</view>
		<view class="ddzx" style="margin-bottom: 10px;">
			<view class="">
				购买账户
			</view>
			<view class="">
				账户名:{{obk.nickname}}
			</view>
			<view class="">
				联系电话:{{obk.mobile}}
			</view>

		</view>
		<view class="ddzx" style="margin-bottom: 10px;">
			<view class="">
				结算
			</view>
			<view class="">
				订单原价:{{obk.totalFee}}
			</view>
			<view class="">
				活动优惠:0
			</view>
			<view class="">
				需支付金额:{{obk.totalFee}}
			</view>

		</view>
		<view class="bnottom">
			<button type="default" @click="qfk"
				style="width:100px;margin-right:15px; color: #fff;background-color: #ff7a38;border-radius:20px;float:right;"
				size="small">去付款</button>
		</view>
	</view>
</template>
<style>
	.bnottom {
		position: fixed;
		bottom: 0px;
		left: 0px;
		width: 100%;
		height: 80px;
		padding-top: 20px;
		box-sizing: border-box;
		background: #fff;
	}
</style>
<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		ref
	} from 'vue';
	import instance from '../../request';
	onLoad(e => {
		console.log(e)
		addorder(e)
	})
	const obk = ref({});
	const qfk = async () => {
		const res = await instance.get(`/api/order/webChat/createJsapi/${obk.value.orderNo}`)
		console.log(res)
		pay(res.data)
	}
	const pay = async (obj) => {
		let params = {
			...obj,
			provider: 'wxpay',
			orderInfo: ''
		}
		const payinfo = await uni.requestPayment(
			params)
	}
	const addorder = async (e) => {
		const res = await instance.post(`/api/order/auth/save/${e.id}`)
		console.log(res)
		const res1 = await instance.get(`/api/order/auth/get/${res.data.orderId}`);
		console.log(res1)
		obk.value = res1.data.item
	}
</script>

<style>
	.bnottom {
		position: fixed;
		bottom: 0px;
		left: 0px;
		width: 100%;
		height: 80px;
		padding-top: 20px;
		box-sizing: border-box;
		background: #fff;
	}

	page {
		width: 100%;
		height: 100%;

	}

	.ddzx {
		width: 100%;
		height: auto;
		padding: 10px;
		box-sizing: border-box;
		background: #fff;

	}

	.global {
		width: 100%;
		height: 100%;
		padding: 10px;
		box-sizing: border-box;
		background-color: rgba(78, 52, 37, 0.2);
	}
</style>